package util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by fenglixiong on 2017/10/3.
 */
public class CookieUtils {

    public static String getCookieValue(String cookies, String cookieName){
        Pattern pattern = Pattern.compile("(^| )" + cookieName + "=([^;]*)(;|$)");
        Matcher matcher = pattern.matcher(cookies);
        if(matcher.find()){
            System.out.println(matcher.groupCount());
            for(int i=0;i<=matcher.groupCount();i++){
//                System.out.println("group" + i + "\t" + matcher.group(i));
            }
            if(matcher.groupCount()==3) {
                return matcher.group(2);
            }
        }
        return null;
    }

}
